const http = require("http");
const fs = require("fs");
const path = require("path");
let filePath = '';
let fileName = process.argv[2];
if (fileName) {
    filePath = path.join(__dirname, fileName);
} else {
    filePath = path.join(__dirname, 'fileReader1.js');
}

http.createServer((req, res) => {
    fs.readFile(filePath, (err, data) => {
        if (err) {
            console.log(err);
        } else {
            // console.log(data.toString())
            res.end(data.toString());
        }
    })
}).listen(8081);


//查询防火墙可用端口 sudo firewall-cmd --list-ports
// sudo firewall-cmd --zone=public --add-port=8081/tcp --permanent  开启指定端口
// sudo firewall-cmd  --reload  重启防火墙